﻿using DimensionsHelper.LanguageService.Protocol;

namespace DimensionsHelper.LanguageService.Syntax;

public abstract class AbstractTextRange : ITextRange
{
    public DocumentUri Uri { get; protected set; } = DocumentUri.Empty;

    public virtual TextSpan Span => TextSpan.Create(Uri, Start, Width);

    public virtual int Start { get; protected set; }

    public int StartLine { get; private set; }

    public virtual int End => Start + Width;

    public int EndLine { get; private set; }

    public virtual int Width { get; protected set; }

    public virtual string Text { get; protected set; } = string.Empty;

    public virtual bool IsEmpty => Width == 0;

    public virtual bool IsComment => false;

    public void Offset(int offset)
    {
        Start += offset;
    }


    internal void UpdateLine(int startLine, int endLine)
    {
        StartLine = startLine;
        EndLine = endLine;
    }


    internal virtual void SetUri(DocumentUri uri)
    {
        Uri = uri;
    }
}